/**
 * Created by gongxun on 17/1/8.
 */

var GameVersion = function(){
    var that = {};

    that.init = function(){
        //初始化
        if (cc.sys.isNative){
            var writablePath = jsb.fileUtils.getWritablePath();
            cc.log("write path:" + writablePath);

            //添加搜索目录 优先本地位置
            var searchPaths = [
                writablePath,
                ""
            ];
            jsb.fileUtils.setSearchPaths(searchPaths);

        }

        that.start();
        return;


        //版本控制
        if (cc.sys.isNative){
            cc.loader.loadJs(["src/gameAssetsManager.js"], function(err){
                mo.gameAssetsManager();
            });
        }else{
            //加载通用js
            that.start();
        }
    };

    that.start = function(){
        //加载通用js
        cc.loader.loadJs(["src/files.js"], function(err){
            cc.loader.loadJs(Files, function(err){
                cc.LoaderScene.preload(Resource, function () {
                    cc.director.runScene(new MainScene());
                    mo.sceneHelper.loadAll();
                    mo.sceneHelper.intoLoginLayer();
                }, this);
            });
        });
    };

    that.html5Start = function(){
        cc.LoaderScene.preload(Resource, function () {
            cc.director.runScene(new MainScene());
            mo.sceneMainLayer.setAnchorPoint(cc.p(0, 0));
            mo.sceneMainLayer.setRotation(90);
            mo.sceneMainLayer.setPosition(cc.p(0, mo.curSize.x));

            mo.sceneHelper.loadAll();
            mo.sceneHelper.intoLoginLayer();
        }, this);
    };

    return that;
};

mo.gameVersion = new GameVersion();